<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Hook;

class Integralorder extends Api
{

    /**
     * Name: 积分订单下单
     * Date: 2021/12/18 21:15
     */
    public function add()
    {
        $params = $this->request->post();
        $data   = [
            'user'      => &$this->auth,
            'address'   => $params
        ];
        Hook::listen('user_region_handle', $data);
        
        $params['region_id']        = $this->auth->region_id;
        $params['user_id']  = $this->auth->id;
        $params['images']   = isset($params['images']) ? $params['images'] : '';

        $orderModel = new \app\common\model\IntegralOrder();
        if (!$orderModel->add($params)) {
            $this->error($orderModel->getError());
        }

        $this->success();
    }
}